<?php
//判断是否正当访问
if(!defined('IN_DISCUZ') || empty($_G['formhash']) || empty($_G['uid']) || empty($_G['gp_tid']) || !submitcheck('activitycancel')) {
	exit('Access Denied');
}

require_once DISCUZ_ROOT.'./source/plugin/donkey_activity/donkey_activity.func.php';
//判断活动状态
$activity = get_activity('stop');

//获取表单参数，reason
$message = cutstr(dhtmlspecialchars($_G['gp_message']), 200);

$applyinfo = array();
$applyinfo = DB::fetch_first("SELECT * FROM ".DB::table('donkey_activity_apply')." WHERE tid='$_G[gp_tid]' AND uid='$_G[uid]'");
if(!$applyinfo) {
	showmessage('您没有报名，不需要取消');
}

//TODO, 报名人数
//DB::update('forum_activity', array('applynumber' => $applynumber), "tid='$_G[tid]'");

if($activity['uid'] != $_G['uid']) {
	notification_add($activity['uid'], 'activity', 'activity_cancel', array(
		'tid' => $_G['gp_tid'],
		'subject' => $thread['subject'],
	));
}
DB::query("DELETE FROM ".DB::table('donkey_activity_apply')." WHERE tid='$_G[gp_tid]' AND uid='$_G[uid]'", 'UNBUFFERED');
showmessage('取消报名成功！', 'forum.php?mod=viewthread&tid='.$_G[gp_tid]);
?>